<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
use think\facade\Route;

Route::get('truncate', 'creation/trunData');


Route::group(function () {

  // 网站首页
  Route::get('/', 'index/index');

  // 文章列表
  Route::get('php/[:page]', 'article/list')->append(['main_id' => 100]);
  Route::get('mysql/[:page]', 'article/list')->append(['main_id' => 101]);
  Route::get('web/[:page]', 'article/list')->append(['main_id' => 102]);
  Route::get('python/[:page]', 'article/list')->append(['main_id' => 103]);
  Route::get('golang/[:page]', 'article/list')->append(['main_id' => 104]);
  Route::get('algorithm/[:page]', 'article/list')->append(['main_id' => 400]);
  Route::get('seo/[:page]', 'article/list')->append(['main_id' => 500]);
  Route::get('source/[:page]', 'article/list')->append(['main_id' => 501]);
  Route::get('essay/[:page]', 'article/list')->append(['main_id' => 502]);

  // 文章搜索
  Route::get('search/[:keys]', 'article/search');
})->middleware([
  \app\middleware\GetAdminInfo::class, // 验证登陆信息
]);



Route::group(function () {

  // 文章页面
  Route::get(':akey$', 'article/article')->pattern(['akey' => '[0-9a-zA-Z]{7}']);
})->middleware([
  \app\middleware\GetAdminInfo::class,
  \app\middleware\CheckArticleId::class, // 转换文章akey
]);








// 留言面板
Route::group(function () {

  // 评论功能
  Route::resource('comment', 'Comment');

  Route::post('comment/recall', 'Comment/json_comment_recall');
  Route::post('comment/delete', 'Comment/json_comment_delete');
  Route::rule('comment/update', 'Comment/commentUpdate');

  # 根据留言ID显示留言面板
  Route::get('cms/:commentId$', 'index/comments')->pattern(['commentId' => '[a-zA-Z]+']);
})->middleware([
  \app\middleware\GetAdminInfo::class,
  \app\middleware\CheckArticleId::class,
]);






# 根据文章ID显示博客文章，Hashids('soyulsmida',5) max=3748095 Oaaaa 3748096 D8LLLL 三百七十万
// Route::get(':aid$', 'article/article')->pattern(['aid' => '[0-9a-zA-Z]{5}']);
// Hashids('choaloveyou',4)max=85183 OLLL 85184 MeGGG 8万5千
// Hashids('choaloveyou',3)max=1935  lKK  1936  


// *******************************************************************************************
// 
// *******************************************************************************************

// 登录
// Route::post('login/login', 'login/login');

# 根据链接ID显示链接空间
// Route::get('lks/:spaceId$', 'link/link')->pattern(['spaceId' => '[a-zA-Z]+']);

// 写文章 - 网页版
// Route::group('article', function () {

//   Route::get('/new/ckeditor/[:akey]', 'creation/newCkeditor');

//   Route::post('/new_save/[:akey]', 'creation/newSave');
//   Route::post('/ckeditor5/upload', 'creation/uploadCkeditor5');
// })->middleware([
//   \app\middleware\GetAdminInfo::class,
//   \app\middleware\CheckMustLogin::class,
//   \app\middleware\CheckArticleId::class,
// ]);
